package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController(value = "userCategoryController")
@RequestMapping("/user/category")
public class CategoryController {
    @Autowired
    private ICategoryService categoryService;

    /**
     * 微信用户登录小程序点餐的列表
     * @return
     */
    @Cacheable(value = "categoryCache")
    @GetMapping("/list")
    public Result<List<Category>> list(){
        List<Category> categoryList=categoryService.listCategory();
        return Result.success(categoryList);
    }
}
